from flask import Blueprint, request

newsR = Blueprint('news', __name__)


# 利用的 是装饰器原理
@newsR.route("/")  # 默认是get
def index():
    print(request.url)
    print(request.base_url)
    print(request.host)
    print(request.host_url)
    print(request.headers)
    print(request.path)
    print(request.full_path)
    print(request.form)
    print(request.args)
    print(request.cookies)
    print(request.method)
    return {
        'status': 'ok',
        'data': "sucess"
    }


@newsR.route("/a", methods=['POST'])  # 默认是get
def indexa():
    return {
        'status': 'ok',
        'data': "sucess"
    }


# 动态传参
# //baseurl/b/sushi
# <age:int>  <
@newsR.route("/b")  # 默认是get
def indexb(name):
    return {
        'status': 'ok',
        'data': "sucess",
        'name': name
    }


@newsR.route("/c")
def indexc():
    request.method
    request.form
    return {
        'status': 'ok',
        'data': "sucess"
    }
